package com.design.mode.prototype;

import lombok.Data;

/**
 * @ClassName ProtoTypeCitation
 * @Description TODO
 * @Author xiongchao
 * @Date 2020/9/28 14:10
 **/
public class ProtoTypeCitation {

    public static void main(String[] args) throws CloneNotSupportedException {

        Citation ci = new Citation("王大","同学: 在2020年荣获优秀毕业生称号.","华中科技大学");
        Citation ca = (Citation) ci.clone();
        ca.setName("佩琪");

        ci.display();
        ca.display();
    }
}

@Data
class Citation implements Cloneable{

    String name;

    String info;

    String collage;

    Citation(String name,String info,String collage){
        this.name = name;
        this.info = info;
        this.collage = collage;

        System.out.println("创建模版成功");
    }

    public Object clone() throws CloneNotSupportedException {
        System.out.println("copy模版成功");
        return super.clone();
    }

    void display(){
        System.out.println(name + info +collage);
    }



}
